package com.qf.rbac2202.shiro;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.stereotype.Component;

/**
 * 让freemark 模板中的 <#if shiro.hasPermission("sys:user:save")> 生效
 */
@Component
public class ShiroTag {

    public boolean hasPermission(String permission){

        final Subject subject = SecurityUtils.getSubject();

        return permission!=null && subject.isPermitted(permission);

    }

}
